<template>
    <header class="pub-head">
        <div class="head-box flex jus-b" :class="{'bottom-border':isBorder=='true'}">
            <div class="left flex" v-if="isIndex == 'false'" @click="back">
                <img src="~@/assets/back.png" alt="">
            </div>
            <div class="left flex" v-if="isIndex == 'true'">
            </div>
            <router-link :to="'/'" class="title flex">
                <img src="~@/assets/logo.png" alt="">
            </router-link>
            <div class="right flexc" @click="menu">
                <img src="~@/assets/menu.png" alt="">
            </div>
        </div>

        <!-- 导航弹窗 -->
        <div class="top-menu" v-show="nav == true" @click="nav = false"></div>
        <div class="menu-list flex" v-show="nav == true">
            <ul class="flex1">
                <li class="flex" v-for="(item,index) in items" :key="index">
                    <router-link :to="item.lian" class="flex1 flex">
                        <div class="flex list-img">
                            <img :src="item.img" alt="">
                        </div>
                        <p class="list-name flex1">{{item.name}}</p>
                    </router-link>
                </li>
            </ul>
        </div>

    </header>
</template>

<script>
import { mapState } from 'vuex';
export default {

    data () {
        return {
            items:[],
            bgcor: this.bgColor,
            nav: false, // 是否显示导航栏
        }
    },
    created(){
        this.axios.get('http://jxjq.0791jr.com/index.php?m=App&c=Index&a=sideNav', {
            params: {
                uid: this.$store.state.user.uid
            }
        }).then(res => {
            if(res.status == 200){
                const data = res.data.data;
                this.items = data.nav;
            }
        })
    },
    
    props: {
        // 头部标题
        title: {
            type: String,
            default: '标题'
        },
        titleColor: {
            type: String,
            default: '#333'
        },
        // 头部背景色
        bgColor: {
            type: String,
            default: '#fff'
        },
        bgchange: {

        },
        // 头部主题色
        themeColor: {
            type: String,
            default: 'false'
        },
        // 左边图标颜色
        leftColor: {
            type: String,
            default: '#333'
        },
        // 右边文字尺寸
        rightSize: {
            type: String,
            default: '0.26rem'
        },
        // 右边文字颜色
        rightColor: {
            type: String,
            default: '#333'
        },
        // 边框
        isBorder: {
            type: String,
            default: 'true'
        },
        //是否首页
        isIndex: {
            type: String,
            default: 'false'
        }
        
    },

    computed: {
        ...mapState(['user'])
    },
    methods: {
        // 返回上一页
        back() {
            this.$router.go(-1);
        },

        //导航
        menu() {
            this.nav = !this.nav
        }
    }
}
</script>

<style lang="less" scoped>
 @import url('../style/mixin');
    .pub-head {
        width: 100%;
        height: 0.92rem;
        .head-box {
            position: fixed;
            top: 0;
            width: 100%;
            max-width: 750px;
            height: 0.92rem;
            z-index: 100;
            background-color: #fff;
            .left {
                width: 0.92rem;
                height: 0.92rem;
                img {
                    width: 0.2rem;
                    height: 0.36rem;
                    margin: auto;
                }
            }
            .title {
                line-height: 0.88rem;
                text-align: center;
                font-size: 0.36rem;
                img {
                    width: 1.96rem;
                    height: .6rem;
                    margin: auto;
                }
            }
            .right {
                width: 0.92rem;
                height: 0.92rem;
                img {
                    width: 0.5rem;
                    height: 0.3rem;
                    margin: auto;
                }
            }
        }
        .top-menu {
            width: 100%;
            max-width: 750px;
            height: 100%;
            margin: auto;
            position: fixed;
            z-index: 99;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.6);
        }
        .menu-list {
            width: 5.4rem;
            height: auto;
            position: fixed;
            z-index: 99;
            top: 0.92rem;
            right: 0;
            li {
                width: 100%;
                height: 1.1rem;
                padding: 0 0.26rem;
                font-size: 0.3rem;
                background-color: #fff;
                border-bottom: 1px solid #e6e6e6;
                .list-img {
                    width: 0.68rem;
                    height: 0.68rem;
                    margin: auto 0;
                    overflow: hidden;
                    img {
                        width: 100%;
                        height: 100%;
                    }
                }
                .list-name {
                    margin-left: 0.2rem;
                    line-height: 1.1rem;
                    background: url('~@/assets/to.png') no-repeat right center;
                    background-size: 0.12rem 0.24rem;
                }
            }
            li:last-child {
                border-bottom: none;
            }
        }
        
        // 主题色
        .head-red {
            .bg-cor-ltr(#36a9eb, #3c93ea);
        }
        .seat {
            height: 0.88rem;
        }    
        .bottom-border {
            border-bottom: 1px solid #ededed;
        }
    }
</style>
